<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.org/ui">

<h:head>
<link type="text/css" href="css/jquery-ui-1.8.20custom.css" rel="stylesheet" />
</h:head>

<h:body  style="background-color: #e3fff6;" >



	<h:form id="form01">
	
	<p:panel header="Cadastro de Empresa" style="font-size:13px;" >
			<p:growl id="growl" autoUpdate="true" showDetail="false" sticky="true" />
			  
    
		<h:panelGrid id="empresa" columns="6" cellpadding="5">
		
			<h:outputText value="Nome do Empresa:" />
			<p:inputText value="#{empresaMB.empresa.nome}" required="true" requiredMessage="Nome Obrigatorio"/>
			
			<h:outputText value="Endereço:"/>
			<p:inputText value="#{empresaMB.empresa.endereco}"/>
			
			 <h:outputText value="Cidade: " />
						<p:selectOneMenu value="#{empresaMB.idcidade}" required="true" requiredMessage="Cidade Obrigatorio">
								<f:selectItem itemLabel="-----" itemValue="" />
							<f:selectItems value="#{empresaMB.cidadeList}" var="est"
								itemLabel="#{est.nome}" itemValue="#{est.id}" />
			</p:selectOneMenu>	
			
				
									
			<h:outputText value="Telefone:" requiredMessage="Digite um numero"/>
			<p:inputMask value="#{empresaMB.empresa.telefone}" mask="(99)9999-9999"/>	
							
			<h:outputText value="Numero do contrato:"/>
			<p:inputText value="#{empresaMB.empresa.numerocontrato}"/>
						
			<h:outputText value="CPF:"/>
			<p:inputText value="#{empresaMB.empresa.cpf}"/>
						
       		<h:outputText value="RG:"/>
			<p:inputText value="#{empresaMB.empresa.rg}"/>
       		
		</h:panelGrid>
		
			<p:commandButton value="Salvar" action="#{empresaMB.salvar}"  actionListener="$bean.clearValues" update="form01" style="font-size:13px;" >
			<f:ajax execute="@form" render="@form" />
			</p:commandButton>
		
			<p:commandButton value="Excluir" action="#{empresaMB.excluir}" actionListener="$bean.clearValues" update="form01" style="font-size:13px;" immediate="true" >
				<f:ajax execute="@form" render="@form" />
			</p:commandButton>
			
				<p:link outcome="menu.jsf" value="Voltar ao Menu">
			</p:link>
			
			<p:panel header="Lista de Empresa" style="font-size:13px;" >
			
			
			<p:dataTable var="c" value="#{empresaMB.empresaList}" widgetVar="pessoaTable" filteredValue="#{empresaMB.empresaListempresa}" 
			 paginator="true" rows="10"  rowsPerPageTemplate="5 10 15 20" >
			 
		  <f:facet name="header">
            <p:outputPanel>
                <h:outputText value="Pesquisa:" />
                <p:inputText id="globalFilter" onkeyup="PF('pessoaTable').filter()" style="width:150px" placeholder="Enter keyword"/>
            </p:outputPanel>
        </f:facet>
			
			
		 <p:column filterBy="#{c.id}" headerText="Id">  
                
                <h:outputText value="#{c.id}" filterMatchMode="contains"/>  
            </p:column> 
            
		 <p:column filterBy="#{c.nome}" headerText="Nome">  
                
                <h:outputText value="#{c.nome}" filterMatchMode="contains"/>  
            </p:column>
			
			<p:column>
				<f:facet name="header">Endereço:</f:facet>
    				#{c.endereco}
			</p:column>
			
			<p:column>
				<f:facet name="header">Cidade:</f:facet>
    				#{c.idCidade.nome}
			</p:column>
			
			
				<p:column>
				<f:facet name="header">Telefone:</f:facet>
    				#{c.telefone}
			</p:column>
				
			
			<p:column>
				<f:facet name="header">CPF:</f:facet>
    				#{c.cpf}
			</p:column>
			
			<p:column>
				<f:facet name="header">RG:</f:facet>
    				#{c.rg}
			</p:column>
			<p:column>
					<f:facet name="header">Editar</f:facet>
						<p:commandButton process="@this" value="Editar" update=":form01" >
						<f:setPropertyActionListener target="#{empresaMB.empresa}" value="#{c}" />
							</p:commandButton>
						</p:column>
			

		</p:dataTable>
		
	</p:panel>
	</p:panel>
	</h:form>
	
</h:body>
</html>